import axios from 'axios'
import qs from 'qs'
import { host } from './../config/index'
import { upLoadUrl,upVideoUrl } from './../config/index'

// axios.defaults.baseURL = '/api';
axios.interceptors.request.use( (config)=> {
    if(config.url !== upLoadUrl && config.url !== upVideoUrl){
        config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
        if (config.method === 'post') {
            config.data = qs.stringify({
                ...config.data
            })
        }
    }else{
        config.headers['Content-Type'] = 'multipart/form-data'
    }
    return config;

}, function (error) {
    loadinginstace.close()
    return  Promise.reject(error);
})
// 获取mstr
export const getMstr = () => axios.post(`${host}api/Oauth/getWxLoginUrl`);

// 获取userinfo
export const userinfo = (mstr) => axios.post(`${host}api/huanzhe/userinfo`, {
    mstr
});

//更新用户信息
export const updateuserinfo = (options) => axios.post(`${host}api/huanzhe/updateuserinfo`, options);

//绑定医生
export const binddoctorid  = (options) => axios.post(`${host}api/huanzhe/binddoctorid`, options);

//症状分类
export const getillness  = (mstr) => axios.post(`${host}api/huanzhe/getillness`, {
    mstr
});

//搜索医生
export const searchdoctor  = (mstr,keyword,pageLimit,pageNum) => axios.post(`${host}api/huanzhe/searchdoctor`, {
    mstr,
    keyword,
    pageLimit,
    pageNum
});

//我的医生列表
export const mydoctors  = (mstr) => axios.post(`${host}api/huanzhe/mydoctors`, {
    mstr,
});

//我绑定的医生详情
export const mydoctorsinfo  = (mstr,doctorid) => axios.post(`${host}api/huanzhe/mydoctorsinfo`, {
    mstr,
    doctorid
});

//医生详情
export const doctorsinfo  = (mstr,doctorid) => axios.post(`${host}api/huanzhe/doctorinfo`, {
    mstr,
    doctorid
});

//医生评价
export const doctorcomment  = (mstr,doctorid,pageLimit,pageNum) => axios.post(`${host}api/huanzhe/doctorcomment`, {
    mstr,
    doctorid,
    pageLimit,
    pageNum,
    
});

//获取验证码
export const sendsms  = (mstr,mobile) => axios.post(`${host}api/huanzhe/sendsms`, {
    mstr,
    mobile
});

//获取病例
export const merecipebill  = (mstr,patientid,doctorid) => axios.post(`${host}api/huanzhe/merecipebill`, {
    mstr,
    patientid,
    doctorid
});

//提交反馈单
export const patientfeedback  = (mstr,doctorid,registrationid,recipeid,content,img1,img2,img3) => axios.post(`${host}api/huanzhe/patientfeedback`, {
    mstr,
    doctorid,
    registrationid,
    recipeid,
    content,
    img1,
    img2,
    img3
});

//获取我的抓药信息
export const myrecipebill  = (mstr,type,pageLimit,pageNum) => axios.post(`${host}api/huanzhe/myrecipebill`, {
    mstr,
    type,
    pageLimit,
    pageNum
});

//提交问诊单基本信息
export const editregistration  = (options) => axios.post(`${host}api/huanzhe/editregistration`,options);

//患者端获取问诊单题目
export const getInquirylist  = (mstr,patientid,doctorid) => axios.post(`${host}api/huanzhe/getInquirylist`,{
    mstr,
    patientid,
    doctorid
});

//查看问诊单题目结果
export const seeInquiryList  = (mstr,id) => axios.post(`${host}api/huanzhe/seeInquiryList`,{
    mstr,
    id
});

//患者填写问诊单
export const saveInquirylist  = (options) => axios.post(`${host}api/huanzhe/saveInquirylist`,options);

//药态详情
export const drugstatinfo  = (mstr,drugstateid) => axios.post(`${host}api/huanzhe/drugstatinfo`,{
    mstr,
    drugstateid
});

//获取公共信息
export const webconfig  = (mstr) => axios.post(`${host}api/huanzhe/webconfig`,{
    mstr,
});

//获取处方详情
export const recipebillinfo  = (mstr,recipeid) => axios.post(`${host}api/huanzhe/recipebillinfo`,{
    mstr,
    recipeid
});

//支付处方
export const payrecipe  = (options) => axios.post(`${host}api/huanzhe/payrecipe`,options);


//新增我的收获地址
export const myReceiptAddress  = (options) => axios.post(`${host}api/huanzhe/myReceiptAddress`,options); 

//验证处方手机号码
export const validateRecipe  = (mstr,recipeid,mobile) => axios.post(`${host}api/huanzhe/validateRecipe`,{
    mstr,
    recipeid,
    mobile
}); 

//验证处方手机号码
export const orginfo  = (mstr,my_lat,my_lng) => axios.post(`${host}api/huanzhe/orginfo`,{
    mstr,
    my_lat,
    my_lng
});

//获取指定门诊信息
export const getorginfoone  = (mstr,orgid) => axios.post(`${host}api/huanzhe/getorginfoone`,{
    mstr,
    orgid
});

//更新购买处方寄送门诊接口
export const saverecipebilldrugstore  = (mstr,clinicid,recipeid) => axios.post(`${host}api/huanzhe/saverecipebilldrugstore`,{
    mstr,
    clinicid,
    recipeid
});

//查看物流
export const checkexpress  = (mstr,express_id) => axios.post(`${host}api/huanzhe/checkexpress`,{
    mstr,
    express_id
});

//获取聊天记录
export const chatLog  = (mstr,me_id,to_id,status,page,page_size) => axios.post(`${host}api/huanzhe/chatLog`,{
    mstr,
    me_id,
    to_id,
    status,
    page,
    page_size
});

//打赏支付
export const payreward   = (mstr,money,doctorid,registrationid) => axios.post(`${host}api/huanzhe/payreward`,{
    mstr,
    money,
    doctorid,
    registrationid
});
 
//提价评价
export const evaluatedoctor   = (mstr,doctorid,commenttext,level1,lable1,lable2,lable3,lable4,lable5,lable6,registrationid) => axios.post(`${host}api/huanzhe/evaluatedoctor`,{
    mstr,
    doctorid,
    commenttext,
    level1,
    lable1,
    lable2,
    lable3,
    lable4,
    lable5,
    lable6,
    registrationid
});

//获取最新挂号单
export const getnewregistrationid   = (mstr,patientid,doctorid) => axios.post(`${host}api/huanzhe/getnewregistrationid`,{
    mstr,
    patientid,
    doctorid
});

//挂号支付
export const payregistration   = (mstr,amount,registrationtype,patientid,doctorid,srcregid) => axios.post(`${host}api/huanzhe/payregistration`,{
    mstr,
    amount,
    registrationtype,
    patientid,
    doctorid,
    srcregid
});

//获取微信sdk参数
export const createWeixinJssdk   = (mstr,url) => axios.post(`${host}api/huanzhe/createWeixinJssdk`,{mstr,url});

//确定收货
export const collectGoods   = (mstr,recipeid) => axios.post(`${host}api/huanzhe/collectGoods`,{mstr,recipeid});

//确定收货
export const upVoiceUrl   = (mstr,serverId) => axios.post(`${host}api/huanzhe/downWxVoice`,{mstr,serverId});